MuiAjaxFn('client/orderinfo/selectbynumber', {'orderNumber':GetQueryString("orderNumber")}, function(data) {
	if(data.dataResultList.length!=0){
		data = data.dataResultList[0];
		console.log(data)
		//当前地址
		var addresshtml = '<div class="A-top">' +
			'<div class="A-name">收货人：<b id="realname">' + data.contactName + '</b><span id="pmobile">' + data.contactPhone + '</span></div> ' +
			'<div class="A-address">收货地址：<span id="address">'+data.orderAddress+'</span></div> <input type="hidden" id="zip">' +
			'</div>'
				
		$(".add_address").html(addresshtml)//地址
		
		
		//商品信息
		$(".detalist").empty();
		var Producthtml =  '';
		$.each( data.orderCommodityVo, function(idx , obj) {
			var VoObj = obj.dataResultObj;
			var presentPrice = (obj.commodityPrice / 100).toFixed(2);
			Producthtml += '<div class="detail_top orderli clearfix" data-cNum="' + obj.commodityNumber + '" data-count="' + obj.buyAmount + '">' +
				'<div class="details_img mui-col-xs-4" style="background-image:url('+IMGUrl+''+VoObj.mainPhoto+')">' +
				'</div>' +
				'<div class="details_text mui-col-xs-8">' +
				'<p><span class="name">' + VoObj.title + ' </span><span class="price">￥' + presentPrice + '</span></p>' +
				'<p class="count"><span>x' +  obj.buyAmount + '</span></p>' +
				'<span class="white mark">官方配送</span>' +
				'</div>' +
				'</div>';
//			var ssjj = ($(".count span").html()).substring(1) * ($(".price").html()).substring(1)
	
			//		console.log(data)
//			if(goodsAllPrice) {
//				$(".Allprice").html("￥" + goodsAllPrice)
//			} else {
//				$(".Allprice").html("￥" + ssjj)
//			}
		});
		
		$(".detalist").html(Producthtml);
//		
//		//商品信息补充图片
//		$.each($(".orderli "), function(idx, obj) {
//			var commoditynumber = $(".orderli:eq(" + idx + ")").attr("data-cNum");
//			AjaxNoLGettFn("api/bizcommodity/selectbynumber?adcode=100000&commoditynumber=" + commoditynumber, {}, function(jsondata) {
//				//查询单个商品详情 补全信息
//				$(".orderli:eq(" + idx + ") .details_img ").css({
//					"background-image": "url(" + IMGUrl + "" + jsondata.dataResultObj.mainPhoto + ") "
//				});
//				
//			})
//
//		})
		
		
		$(".Allprice").html('￥'+(data.paymentAmount/100).toFixed(2));//总价
		$(".Allnum").html(data.orderCommodityVo.length);//总数量
		$(".confirm ").html(Ordermenu(data.orderState,data.paymentState,data.evaluationState));//对应的状态按钮
		
		menuTap()//按钮的点击事件绑定
		
	}
})



function Ordermenu(orderState, paymentState, evaluationState) {
	//处理当前的订单状态
	console.log(orderState + '  ' + paymentState)
	if(paymentState == 'PendingPay') {
		//待付款
		$('.toptitle').html("待付款");
		$(".toptitle").addClass("icon-daifukuanb");
		return '<div class="mui-col-xs-4 fixedbtn RSubmitbtn">立即付款</div>';
		
	} else if(paymentState == 'Success') {
		//付款成功后
		
		if(orderState == 'Waiting_for_delivery') {
			//等待发货
			$('.toptitle').html("等待发货");
			$(".toptitle").addClass("icon-daifahuo2");
			return '<div class="mui-col-xs-4 fixedbtn remindCom">提醒发货</div>';
			
		} else if(orderState == 'Already_shipped') {
			//待收货
			$('.toptitle').html("待收货");
			$(".toptitle").addClass("icon-daishouhuo");
			return '<div class="mui-col-xs-4 fixedbtn completebtn">确认收货</div>';
			
		}
	} else if(paymentState == 'Complete' && orderState == 'Complete') {
		//订单完成
		$('.toptitle').html("交易成功");
		$(".toptitle").addClass("icon-yes");
		if(evaluationState == 0) {
			
			return '<div class="mui-col-xs-4 fixedbtn">立即评价</div>'+
				   '<div class="mui-col-xs-4 fixedbtn">退款/售后</div>'
		} else {
			return '<div class="mui-col-xs-4 fixedbtn">退款/售后</div>';
			
		}

	} else if(paymentState == 'Refund_Error') {
		$('.toptitle').html("退款失败");
		$(".toptitle").addClass("icon-shibai");
		return '<div class="mui-col-xs-4 fixedbtn">退款/售后</div>';
	

	} else if(paymentState == 'Refund_Success') {
		$(".toptitle").addClass("icon-yes");
		$('.toptitle').html("退款成功");
		return '<div class="mui-col-xs-4 fixedbtn">退款/售后</div>';


	}

	//待付款 paymentState = PendingPay
	//orderProcess
	//等待发货 Waiting_for_delivery  Success 
	//等待收货 Already_shipped Success
	//订单完成 Complete Complete
	//evaluation_state 1已评价 0未评价
}



function menuTap() {
	$(".RSubmitbtn").on("tap", function() {
		//重新付款
		RSubmitOrder(GetQueryString("orderNumber"));
		
	})
	$(".completebtn").on("tap", function() {
		//确认收货
		
		CompleteOrder(GetQueryString("orderNumber") );
			//http://hsmytest.vrdete.com/client/orderinfo/ordercomplete 确认收货
	})
	
	//提醒发货
	$(".remindCom").on("tap",function(){
		mui.toast("已提醒卖家尽快发货！")
	})
	
	
	
}


